<script type="text/javascript">
/*----------------------------------------------------------
 Dialog
 ----------------------------------------------------------*/
function diglogRenderCsv()
{
    $("#diaglog_move_history").html('<iframe id="modalIframeId" '
        + 'width="100%" height="560px" '
        + 'marginWidth="0" marginHeight="0" '
        + 'frameBorder="0" scrolling="no" />').dialog("open");
    var url = "<?php echo Yii::app()->createUrl('shipment/popup/clientProductList?')?>"
        + "client=" + clientId
        + "&start=" + startDate;
        $("#modalIframeId").attr("src", url);
    return false;
}

/*----------------------------------------------------------
 EVENT
 ----------------------------------------------------------*/
$('#button-refresh').click(function(){
    window.location.reload(true);
});
$('#button-search-refresh').click(function(){
    window.location = "<?php echo Yii::app()->createUrl('shipment/'); ?>";
});
$('#button-submit').click(function(){
    $('form').submit();
    return false;
});
/*----------------------------------------------------------
 Show messages
 ----------------------------------------------------------*/
function showMessageSuccess(type)
{
    if (type === 1) //delete
        content = 'Deleted';
    else if (type === 2) //create
        content = 'Created';
    else if (type === 3) //update
        content = 'Updated';
    else
        content = 'error';

    $('#message-success').text(content);
    $('#message-success').show();
    setTimeout(function() {
        $("#message-success").hide();
    }, 5000);
}

function showConfirmDelete()
{
    answer = confirm('<?php echo Yii::t('msg', 'delete.confim') ?>');
    if (answer) {
        urlDelete = '<?php
            echo $this->createUrl('delete', array(
                    'id' => Yii::app()-> request-> getQuery('id')
            ));
            ?>';
        urlIndex = '<?php echo $this->createUrl('index'); ?>';
        $.post(urlDelete, '', function(){
            window.location = urlIndex;
        });
    }
}

function showConfirmSave(form, data, hasError)
{
    if (! hasError)
    {
        answer = confirm("<?php echo Yii::t('msg','edit.confirm')?>");
        return (answer) ? true : false;
    }
}
</script>